home *** CD-ROM | disk | FTP | other *** search
/ Java 1996 August / Java - Summer 1996.iso / kaffe-0.2 / lib / native / java.lang / java.lang.Object.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-12  |  1.4 KB  |  80 lines

  1. /*
  2.  * java.lang.Object.c
  3.  *
  4.  * Copyright (c) 1996 Systems Architecture Research Centre,
  5.  *           City University, London, UK.
  6.  *
  7.  * See the file "license.terms" for information on usage and redistribution
  8.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  9.  *
  10.  * Written by Tim Wilkinson <tim@sarc.city.ac.uk>, February 1996.
  11.  */
  12.  
  13. #include <stdio.h>
  14. #include <assert.h>
  15. #include <memory.h>
  16. #include <native.h>
  17. #include "../../kaffe/classMethod.h"    /* Don't need java.lang.Object.h */
  18. #include "../../kaffe/locks.h"
  19.  
  20. extern object* alloc_object(classes*);
  21.  
  22. /*
  23.  * Generate object hash code.
  24.  */
  25. long
  26. java_lang_Object_hashCode(struct Hjava_lang_Object* o)
  27. {
  28.     return (o->idx);
  29. }
  30.  
  31. /*
  32.  * Return class object for this object.
  33.  */
  34. struct Hjava_lang_Class*
  35. java_lang_Object_getClass(struct Hjava_lang_Object* o)
  36. {
  37.     return (o->mtable->class);
  38. }
  39.  
  40. /*
  41.  * Notify threads waiting here.
  42.  */
  43. void
  44. java_lang_Object_notifyAll(struct Hjava_lang_Object* o)
  45. {
  46.     broadcastCond(o);
  47. }
  48.  
  49. /*
  50.  * Notify a thread waiting here.
  51.  */
  52. void
  53. java_lang_Object_notify(struct Hjava_lang_Object* o)
  54. {
  55.     signalCond(o);
  56. }
  57.  
  58. /*
  59.  * Clone me.
  60.  */
  61. struct Hjava_lang_Object*
  62. java_lang_Object_clone(struct Hjava_lang_Object* o)
  63. {
  64.     object* obj;
  65.  
  66.     obj = alloc_object(o->type);
  67.     memcpy(obj->data, o->data, obj->type->fsize * 4);
  68.  
  69.     return (obj);
  70. }
  71.  
  72. /*
  73.  * Wait for this object to be notified.
  74.  */
  75. void
  76. java_lang_Object_wait(struct Hjava_lang_Object* o, long long timeout)
  77. {
  78.     waitCond(o, timeout);
  79. }
  80.